#include "SysCtrl.h"

void SysCtrl::HMIinit()
{
    int fd = open("/dev/input/event0",O_RDONLY);

    struct input_event touchBuf;
    char xyFlag = 0;

    while(1)
    {
        bzero(&touchBuf,sizeof(touchBuf));
        read(fd,&touchBuf,sizeof(touchBuf));

        if(touchBuf.type == EV_ABS)
        {
            if((touchBuf.code == ABS_X) && (xyFlag == 0))
            {
                printf("(%d,",touchBuf.value);
                xyFlag = 1;
            }
            else if((touchBuf.code == ABS_Y) && (xyFlag ==1))
            {
                printf("%d)\n",touchBuf.value);
                xyFlag = 0;
            }
                
        }

        /*
        if(touchBuf.type == EV_KEY)
        {
            if(touchBuf.code == BTN_TOUCH)
            {
                if(touchBuf.value == 0)
                    break;
            }
        }
        */
    }
    
}

